package com.spark.check

import android.annotation.SuppressLint
import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
import android.view.View
import com.spark.check.model.TaskModel
import com.spark.common.BaseFragment
import kotlinx.android.synthetic.main.frag_stdcheck_notify.*
import me.yokeyword.fragmentation.SupportFragment

/**
 * 标准化检查通知
 */
class StdCheckNotifyFragment : BaseFragment() {
    companion object {
        fun newInstance(): StdCheckNotifyFragment {
            val fragment = StdCheckNotifyFragment()
            val args = Bundle()

            fragment.arguments = args
            return fragment
        }
    }

    override fun contentResId(): Int {
        return R.layout.frag_stdcheck_notify
    }

    @SuppressLint("SetTextI18n")
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        iv_back.setOnClickListener { pop() }
        tv_title.text = "标化检查通知"
        tv_task_name.text = "2017年标准化检查任务"
        tv_task_creator.text = "创建：张三"
        tv_task_createtime.text = "2018年3月24日"
        tv_task_limit.text = "期限：无"
        tv_task_desc.text = "寒蝉凄切，对长亭晚，骤雨初歇。都门帐饮无绪，留恋处，兰舟催发。执手相看泪眼，竟无语凝噎。念去去，千里烟波，暮霭沉沉楚天阔。多情自古伤离别，更那堪，冷落清秋节！今宵酒醒何处？烟柳岸，晓风残月。此去经年，应是良辰好景虚设。便纵有千种风情，更与何人说？"

        val tasksAdpater = TasksAdpater(R.layout.item_task)
        recy_tasks.adapter = tasksAdpater
        recy_tasks.layoutManager = object : LinearLayoutManager(context) {
            override fun canScrollVertically(): Boolean {
                return false
            }
        }
        tasksAdpater.addData(mutableListOf(TaskModel.mock(), TaskModel.mock(), TaskModel.mock(), TaskModel.mock(), TaskModel.mock(), TaskModel.mock()))

        tasksAdpater.setOnItemClickListener { adapter, view, position ->
            parentFragment?.parentFragment?.parentFragment?.let { it as SupportFragment }?.start(StdChkDetailFragment.newInstance())
        }
    }
}

